package com.dy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pojo.entity.DyPermissionEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Set;

/**
 * @ClassName:
 * @Author: 仄言in
 * @Desctiption: (描述)
 * @Date: 2021/6/2 15:01
 * @Version 1.0 (版本)
 */
@Mapper
@Repository
public interface DyPermissionMapper extends BaseMapper<DyPermissionEntity> {
    /**
     * 获取权限信息
     * @param username
     * @return
     */
    @Select("select dy_permission.name from dy_user inner join dy_user_roles " +
            "on dy_user.code=dy_user_roles.user_code inner join dy_roles " +
            "on dy_user_roles.roles_code=dy_roles.code inner join dy_roles_permission " +
            "on dy_roles.code=dy_roles_permission.roles_code inner join dy_permission " +
            "on dy_roles_permission.permission_code=dy_permission.code where username=#{username}")
    Set<String> getPermission(String username);
}
